home *** CD-ROM | disk | FTP | other *** search
- { *****************************************************
- THookButton Component
-
- A trivial example of a component with a TEventList.
-
- Paul Warren
- HomeGrown Software Development
- (c) 1997 Langley British Columbia.
- (604) 856-6523
- e-mail: hg_soft@uniserve.com
- Home page: http://users.uniserve.com/~hg_soft
- ***************************************************** }
-
- unit Hookdbtn;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, Buttons, EList;
-
- type
- THookedButton = class(TSpeedButton)
- private
- { private declarations }
- FEventList: TEventList;
- FHookEvent: TNotifyEvent;
- procedure SetHookEvent(Value: TNotifyEvent);
- protected
- { protected declarations }
- procedure Click; override;
- public
- { public declarations }
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- property HookEvent: TNotifyEvent write SetHookEvent;
- published
- { published declarations }
- end;
-
- procedure Register;
-
- implementation
-
- constructor THookedButton.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FEventList := TEventList.Create;
- end;
-
- destructor THookedButton.Destroy;
- begin
- FEventList.Free;
- inherited Destroy;
- end;
-
- procedure THookedButton.SetHookEvent(Value: TNotifyEvent);
- begin
- FEventList.AddEvent(Value);
- end;
-
- procedure THookedButton.Click;
- var
- i: integer;
- begin
- inherited Click;
- for i := 0 to FEventList.Count-1 do
- begin
- FHookEvent := FEventList.Events[i];
- FHookEvent(Self);
- end;
- end;
-
- { register component on Samples page }
- procedure Register;
- begin
- RegisterComponents('Samples', [THookedButton]);
- end;
-
- end.